package com.wish.wishhouse_foreclosure.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;

@Getter
public enum ContractStateEnum {
    SUBMITED("已提交", 2),
    TERMINATED("已解约", 3),
    ENDED("已结束", 4);
    @JsonValue
    private String name;
    @EnumValue
    private int index;

    private ContractStateEnum(String name, int index) {
        this.name = name;
        this.index = index;
    }

    // 普通方法
//    public static String getName(int index) {
//        for (ContractStateEnum c : ContractStateEnum.values()) {
//            if (c.getIndex() == index) {
//                return c.name;
//            }
//        }
//        return null;
//    }

//    public static Integer getIndex(String name) {
//        for (ContractStateEnum c : ContractStateEnum.values()) {
//            if (c.getName().equals(name)) {
//                return c.getIndex();
//            }
//        }
//        return null;
//    }

    public String getName() {
        return name;
    }

    public int getIndex() {
        return index;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setIndex(int index) {
        this.index = index;
    }
}
